export default {
  namespace: true,
  state: {
    breadcrumbActive: '',
    breadcrumbList: []
  },
  mutations: {
    SET_BREADCRUMB_ACTIVE(state, str) {
      state.breadcrumbActive = str
    },
    ADD_BREADCRUMB(state, item) {
      if (state.breadcrumbList.findIndex(i => i.meta.title === item.meta.title) === -1) {
        state.breadcrumbList.push(item)
      }
    },
    DEL_BREADCRUMB(state, index) {
      if (state.breadcrumbList[index].meta.title === state.breadcrumbActive) {
        state.breadcrumbActive = state.breadcrumbList[index - 1].meta.title
      }
      state.breadcrumbList.splice(index, 1)
    }
  }
}
